package spring.ioc.component;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import spring.ioc.model.Student;

@Component
public class StudentComponenet {
    @Bean({"s3","s4"})//默认为value
//    @Bean(name = {"s3","s4"})
//    @Bean(value ={"s3","s4"})
    //里面括号可以重新命名，然后替换s1这个名字
    //BeanName默认为类名的小驼峰写法,如果类名前俩位均为大写，beanName为类名本身
    //需要搭配五大注解使用
    public Student s1(){
        return new Student("zhangsan","1",18);
    }

//    @Bean
//    public Student s2(){
//        return new Student("lisi","2",19);
//    }

    @Bean
   public String name(){
        return "lisi";
    }

    @Bean
    public String name2(){
        return "lisi2";
    }

    @Bean
    @Primary
    public Student s5(String name){
        return new Student(name,"3",18);
    }

    @Bean
    //@Qualifier可以加到属性上
    //@Qualifier可以指定拿到的参数,也就是public String name2这个.
    public Student s2(@Qualifier("name2") String n){
        return new Student(n,"1",18);
    }

}
